<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let input = `8
        7258 6579 2602 6716 3050 3564 5396 1773`
        // let input=`3
        // 3 5 6`
        input = input.split('\n');
        let apple_num = parseInt(input[0].trim(), 10)

        // 十进制数组
        let apple_lis = input[1].trim().split(' ').map((v) => {
            return parseInt(v.trim())
        })
        console.log(apple_lis);
        let apple_A=0
        let apple_B=0
        apple_lis.forEach((v)=>{
            apple_A^=v
            apple_B+=v
        })        
        if(apple_A===0){
            console.log(apple_B-Math.min(...apple_lis));            
        }else{
            console.log(-1);
            
        }
        
        
        




    </script>
</body>

</html>